package com.woyou.ui.activity.orderdetail;

import com.woyou.bean.Info;
import com.woyou.bean.OrderDetail;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;

/**
 * 订单状态对应的view的creater
 * @author longtao.li
 *
 */
public abstract class StateViewCreater {
	
	public static final String INFO_NAME = "info";
	
	protected Context mContext;
	
	protected Activity mActivity;
	
	protected ViewControl mUiControl;
	
	protected OrderDetail mDetail;
	
	protected View[] mViewArr;
	
	
	public StateViewCreater(Context context, ViewControl uiControl, OrderDetail detail) {
		this.mContext = context;
		this.mUiControl = uiControl;
		this.mDetail = detail;
		this.mActivity = (Activity) context;
		
		createView();
	}
	
	/**
	 * 实例化View[]中的元素和实现事件绑定等操作
	 */
	protected abstract void createView();
	
	public View[] getViewArr(){
		return mViewArr;
	}
	/**
	 * 打开一个Activity
	 * 
	 * @param clazz
	 * @param info
	 */
	@SuppressWarnings("rawtypes")
	public void openActivity(final Class clazz, final Info info) {
		mActivity.runOnUiThread(new Runnable() {

			@Override
			public void run() {
				Intent intent = new Intent();
				intent.setClass(mContext, clazz);
				if (info != null) {
					intent.putExtra(INFO_NAME, info);
				}
				mActivity.startActivity(intent);
			}
		});

	}
}
